<template>
  <div>
    <h1>post json数据请求</h1>
    <br/>
    <button @click="post">点击请求数据</button>
    <hr/>
    <div>
      数据：{{info}}
    </div>
  </div>
</template>

<script>
import axios from "axios";

export default {
  name: 'post-json',
  data(){
    return{
      info: null
    }
  },
  methods:{
    post(){
      let jsonData = {
        param1: 22,
        param2: '12333fsdfs',
        param3: 123.44,
        param4: '2022-09-09 12:12:12'
      };
      axios
        .post('http://localhost:9700/test/post/json', jsonData)
        .then(res => {
          console.log("res = ", res.data);
          this.info = res.data;
        })
        .catch(function (error) { // 请求失败处理
          console.log(error);
        });
    },
  }
}
</script>
